home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1996-01-17 | 4.1 KB | 134 lines |
- ' ************************************* Commands used:
- ' * * Vec Rot Pos Turbo Draw
- ' * Amcaf Examples * Vec Rot Angles Blitter Clear
- ' * Vector Rotate Wire + Fade V1.1 * Vec Rot Precalc =Qsin
- ' * Written by Chris Hodges * =Vec Rot X
- ' * * =Vec Rot Y
- ' ************************************* =Vec Rot Z
- '
- ' Hide mouse pointer.
- Hide
- ' Setup a nice little screen with double buffering
- Screen Open 0,320,256,8,Lowres
- Curs Off : Flash Off : Paper 0 : Pen 1 : Cls
- Palette 0,0,0,0
- Double Buffer
- Autoback 0
- ' Read out, how many coords are used.
- Restore COORDS
- Read NUMCO
- ' Dim one field to keep these coords, and a second for the rotated.
- Dim CO(NUMCO,2),RC(NUMCO,1)
- ' Now read all coords in.
- For A=1 To NUMCO
- Read CO(A,0),CO(A,1),CO(A,2)
- Next
- ' Then, get the number of lines the object consists of.
- Restore LINES
- Read NUMLI
- ' Dim a field to hold the startcoord and the endcoord.
- Dim LI(NUMLI,1)
- ' Get the datas.
- For A=1 To NUMLI
- Read LI(A,0),LI(A,1)
- Next
- ' Set the three angles. Remember that these are non standard angles,
- ' one full rotation is at 1024, not 360!
- AX=0 : AY=512 : AZ=128
- ' New: BP contains the bitplane, onto which the Cube should be drawn.
- BP=0
- ' Now follow a few colour definitions.
- ' C1 holds the brightest colour, C2 a middle one and C3 the darkest.
- CO1=$FFF : CO2=$888 : CO3=$444
- Repeat
- ' Start clearing the plane to be drawn on.
- Extension_8_121C 0,BP
- ' While the blitter is working, use the time to calculate the rotations.
- ' Move and set the angles.
- Add AX,5
- Add AY,8
- Add AZ,11
- Extension_8_1138 AX,AY,AZ
- ' Calculate the distances by using a sine-function and the three angles.
- POSX= Extension_8_1106(AX,300)
- POSY= Extension_8_1106(AY,300)
- POSZ= Extension_8_1106(AZ,500)+1500
- ' Set the camera positions.
- Extension_8_1122 POSX,POSY,POSZ
- ' Now it's time to compute the matrix.
- Extension_8_1152
- ' So let's rotate all coordinates of the field CO()
- For A=1 To NUMCO
- ' Note: You only have to use the vec rot function with parameters once.
- RC(A,0)= Extension_8_1168(CO(A,0),CO(A,1),CO(A,2))+160
- RC(A,1)= Extension_8_1184 +128
- Next
- ' It's time to finally get the lines to the screen!
- For A=1 To NUMLI
- ' Starting coordinates pair.
- C1=LI(A,0)
- ' Ending coordinates pair.
- C2=LI(A,1)
- ' Get the rotated coordinates
- X1=RC(C1,0) : Y1=RC(C1,1)
- X2=RC(C2,0) : Y2=RC(C2,1)
- ' Draw the line on bitplane BP
- Extension_8_1016 X1,Y1 To X2,Y2, Extension_8_04F8(BP), Extension_8_04F8(BP)
- Next
- ' Swap the screens to bring the object to view.
- Screen Swap
- ' Now change the palette, to simulate a fade effect.
- ' It works by looking which colour appears on which planes, and giving
- ' the one being drawn the highest priority. Look at the following table:
- ' If the bit is set, which has a 1 under it, the colour must be 1, because
- ' it has the highest priority. If the bits for 2 and 3 are set, the colour
- ' must be 2 because 2 is only overlapped by the bit 1. etc.pp.lha
- '
- ' Colour-Bits 000,001,010,011,100,101,110,111
- ' Priority 321 321 321 321 321 321 321 321
- If BP=0 Then Palette 0,CO1,CO2,CO1,CO3,CO1,CO2,CO1
- ' Colour-Bits 000,001,010,011,100,101,110,111
- ' Priority 213 213 213 213 213 213 213 213
- If BP=1 Then Palette 0,CO3,CO1,CO1,CO2,CO2,CO1,CO1
- ' Colour-Bits 000,001,010,011,100,101,110,111
- ' Priority 132 132 132 132 132 132 132 132
- If BP=2 Then Palette 0,CO2,CO3,CO2,CO1,CO1,CO1,CO1
- Wait Vbl
- ' Select next bitplane.
- Add BP,1,0 To 2
- Until Inkey$=Chr$(27) or Mouse Key<>0
- Screen Close 0
- End
- ' 1_____2
- ' 5/____/|
- ' | | |6|
- ' |4|__|_|3
- ' |/___|/
- ' 8 7
- COORDS:
- Data 8
- ' CUBE
- Data -100,-100,-100
- Data 100,-100,-100
- Data 100,-100,100
- Data -100,-100,100
- Data -100,100,-100
- Data 100,100,-100
- Data 100,100,100
- Data -100,100,100
-
- LINES:
- Data 12
- ' CUBE
- Data 1,2
- Data 2,3
- Data 3,4
- Data 4,1
- Data 5,6
- Data 6,7
- Data 7,8
- Data 8,5
- Data 1,5
- Data 2,6
- Data 3,7
- Data 4,8